<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>

    html,body{
      margin: 0px;
      padding: 0px;
    }

    /* 父元素 */
    .outer{
      width: 300px;
      height: 300px;
      background: yellowgreen;

      overflow: hidden;           /*嵌套的时候，外边距会跑到外面*/
      /* border-top: 1px solid transparent; */
    }

    .inner{
      width: 100px;
      height: 100px;
      background: red;

      margin-top: 30px;
    }
  </style>
</head>
<body>
  
  <div class="outer">
    <div class="inner"></div>

  </div>
  
</body>
</html>